package com.forest.platform.service.example.controller;

import com.forest.dto.AuthDTO;
import com.forest.dto.AuthEncryptionDTO;
import com.forest.dto.ResultResponse;
import com.forest.platform.service.example.service.SignatureTestService;
import com.forest.util.SignParamUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/signature")
@Api(tags = "签名", value = "SignatureController")
public class SignatureTestController {

    @Resource
    private SignatureTestService signatureTestService;

    @PostMapping("/testVerifySign")
    @ApiOperation(value = "签名测试-普通参数")
    public ResultResponse<String> testVerifySign(@RequestBody AuthDTO dto) {
        return ResultResponse.success(signatureTestService.testVerifySign(dto));
    }

    @PostMapping("/testVerifySignFoeEncryption")
    @ApiOperation(value = "签名测试-参数加密")
    public ResultResponse<String> testVerifySignFoeEncryption(@RequestBody AuthEncryptionDTO dto) {
        return ResultResponse.success(signatureTestService.testVerifySignFoeEncryption(dto));
    }

    @PostMapping("/getSignParam")
    @ApiOperation(value = "获取签名参数")
    public ResultResponse<AuthDTO> getSignParam(@RequestBody Object extra) {
        return ResultResponse.success(SignParamUtil.buildParam("1",  extra));
    }

    @PostMapping("/getSignParamEncryption")
    @ApiOperation(value = "获取签名参数-参数加密")
    public ResultResponse<AuthEncryptionDTO> getSignParamEncryption(@RequestBody Object extra) {
        return ResultResponse.success(SignParamUtil.buildEncryptionParam("1",  extra));
    }
}
